﻿Imports System.Windows.Forms

Public Class Dialog2

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Function selectedradio() As Decimal
        If RadioButton1.Checked Then
            Return 1
        Else
            Return 2
        End If

    End Function
    ''' <summary>
    ''' return the search text and wich colom we want to search
    ''' </summary>
    Public Function searchtext(ByRef searchcolom As String) As String
        If selectedradio() = 1 Then
            searchcolom = "ID"
            Return TextBox1.Text
        Else
            searchcolom = "Name"
            Return TextBox2.Text
        End If
    End Function

    Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If RadioButton1.Checked Then
            RadioButton2.Checked = False
        End If
    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
        If RadioButton2.Checked Then
            RadioButton1.Checked = False
        End If
    End Sub


End Class
